<?php session_start();
$login = $_SESSION['login'];
$privilegio = $_SESSION['privilegio'];

require_once($_SERVER["DOCUMENT_ROOT"] . '/Esquina_da_TI/ClassesBasicas/Privilegio.php');
$forum = $_GET['forum'];
$assunto = $_GET['assunto'];


?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <link href="/Esquina_da_TI/default.css" rel="stylesheet" type="text/css" media="screen" />
        <script src="/Esquina_da_TI/js/jquery-1.3.2.js" type="text/javascript"></script>
        <script src="/Esquina_da_TI/js/exibirPaginas.js" type="text/javascript"></script>
        <script src="/Esquina_da_TI/js/tituloDinamico.js" type="text/javascript"></script>
        <title><?php echo $assunto;?></title>
    </head>
    <body>
        <!--CABEÇALHO-->
        <div id="header">
            <div id="menu">
                <ul id="main">
                    <li><a href="/Esquina_da_TI/index.php"><img src="/Esquina_da_TI/images/home.png" class="menu"  title="Inicio" /><br/><b>Inicio</b></a></li>
                        <li><a href="/Esquina_da_TI/Gui/Forum.php"><img src="/Esquina_da_TI/images/forum.png" class="menu" title="Fórum"/><br/><b>Fórum</b></a></li>
                        <li><a href="javascript:exibirVerNoticia()"><img src="/Esquina_da_TI/images/noticia.png" class="menu" title="Noticia"/><br/><b>Notícias</b></a></li>
                        <li><a href="javascript:exibirVerArtigos()"><img src="/Esquina_da_TI/images/artigo.png" class="menu" title="Artigos"/><br/><b>Artigos</b></a></li>
                        <li><a href="/Esquina_da_TI/Gui/Downloads.php"><img src="/Esquina_da_TI/images/download.png" class="menu" title="Downloads"/><br/><b>Downloads</b></a></li>
                        <li><a href="/Esquina_da_TI/Gui/CadastroUsuario.php"><img src="/Esquina_da_TI/images/Cadastro.png" class="menu" title="Cadastro"/><br/><b>Cadastro</b></a></li>
                        <li><a href="/Esquina_da_TI/Gui/OportunidadeEmprego.php"><img src="/Esquina_da_TI/images/oportunidade.png" class="menu" title="Empregos"/><br/><b>Empregabilidade</b></a></li>
                        <li><a href="javascript:exibirFaleConosco()"><img src="/Esquina_da_TI/images/faleconosco.png" class="menu" title="Fale Conosco"/><br/><b>Fale Conosco</b></a></li>
                        <li><a href="javascript:favoritos()"><img src="/Esquina_da_TI/images/addFavoritos.png" class="menu" title="Add Favoritos"/><br/><b>Favoritos</b></a></li>
                </ul>
            </div>
            <div id="logo">
                <h1><a href="#"><span>Esquina da T.I.</span></a></h1>
                <p>a Tecnologia a seu alcance</p>
            </div>
        </div>
        <div id="wrapper">
            <div id="page">
                <div id="sidebar2" class="sidebar">
                    <?php

                    if (isset ($_SESSION['login'])) {
                        echo " <div id='loginForum'>";
                        echo  "<b><font color =  '#FF7F00'>".$_SESSION['privilegio'] ." >>> </font>". " <font color='#0066ff'>"  . $_SESSION['login']."</font></b></div>";
                        echo " <div id='logoffForum'>";
                        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        echo "<a href='MinhaConta.php'><img src='/Esquina_da_TI/images/minhaConta.png'/></a>";
                        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        echo "<a href='logoff.php'><img src='/Esquina_da_TI/images/logoff.png'/></a>";
                        echo"<br>";
                        echo "<a href='MinhaConta.php'><b><font color='#0066ff'>Minha Conta </font></b></a>";
                        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        echo "<a href='GUI/logoff.php'><b><font color='#0066ff'>Logoff</font></b></a>";
                    }
                    else {
                        echo " <div id='loginForum'>";
                        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        echo "<a href='EfetuarLogin.php'><img src='/Esquina_da_TI/images/login.png'/></a><br>";
                        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        echo "<a href='EfetuarLogin.php'><b><font color='#0066ff'>Fazer Login</font></b></a><br>";
                        echo "<font color =  '#FF7F00'>";
                        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

                        ?>

                    <script language="JavaScript">

                        <!--
                        var d = new Date()
                        var h = d.getHours()

                        if (h < 12)
                            document.write("Bom-dia ! ")
                        else
                            if (h < 18)
                                document.write("Boa-tarde ! ")
                        else
                            document.write("Boa-noite ! ")
                        // -->
                    </script>

                        <?php
                        echo "<b>&nbsp;&nbsp;Visitante</b></font><br>";

                    }

                    echo "</div>";
                    echo "</div>";
                    ?>
                    <br/>
                    <a href='/Esquina_da_TI/Gui/Forum.php'><font style="text-align:left" size="5px" color="Red">Indice dos Foruns</font></a>
                    <font style="text-align:left" size="5px" color="Green">>>></font>
                    <a href='/Esquina_da_TI/Gui/exibirAssuntos.php?forum=<?php echo $forum;?>'><font style="text-align:left" size="5px" color="Red"><?php echo $forum;?></font></a>
                    <font style="text-align:left" size="5px" color="Green">>>></font>
                    <a href='/Esquina_da_TI/Gui/exibirTopicos.php?forum=<? echo $forum;php?>&assunto=<?php echo $assunto;?>'><font style="text-align:left" size="5px" color="Red"><?php echo $assunto;?></font></a>

                    <br/>                   
                    <a href='/Esquina_da_TI/Gui/novoTopico.php?assunto=<?php echo $assunto;?>&forum=<?php echo $forum?>'><img src="/Esquina_da_TI/images/novoTopico.jpg"/></a>
                    &nbsp;

                    <!--CONTEUDO DO CENTRO-->
                    <div align="center" style="border:double">
                        <div class="post" align="center">
                            <form name='forum' method='post' action=''>
                                <table class="forum" cellspacing="1" cellpadding="1">
                                    <tr>
                                        <td width="2%" class="head"></td>
                                        <td width='65%' class="head" colspan="2">Topico</td>
                                        <td width='5%' class="head" colspan="2">Respostas</td>
                                        <td width='15%' class="head" colspan="2">Autor</td>
                                        <td width='30%' class="head" colspan="2">Ultima mensagem</td>
                                    </tr>

                                    <?php
                                    require_once($_SERVER["DOCUMENT_ROOT"] . '/Esquina_da_TI/Gui/Fachada.php');
                                    $fachada = new Fachada();
                                    $topicos = $fachada->listarTopicos($assunto);
                                    foreach($topicos as $t) {
                                        $topico = $t['topico'];
                                        $respostas = $t['respostas'];
                                        $autor = $t['autor'];
                                        $ultimoPost = $t['ultimoPost'];
                                        echo "<tr>";
                                        echo "<td class='forumNum'><img src='/Esquina_da_TI/images/forum.png'/></td>";
                                        echo "<td class='forum' colspan='2'><a href='exibirTopico.php?forum=$forum&assunto=$assunto&topico=$topico'>"  . $topico . "</a></td>";
                                        echo "<td class='forumNum' align='center' colspan='2'>".$respostas."</td>";
                                        echo "<td class='forumNum' colspan='2'>".$autor."</td>";
                                        echo "<td class='forumNum' colspan='2'>".$ultimoPost."</td>";
                                        echo "</tr>";
                                    }
                                    ?>

                                </table>
                            </form>
                        </div>
                        <a href="exibirAssuntos.php?forum=<?php echo $forum?>"><font color="blue"><<<&nbsp;Voltar</font></a>
                        <br><br>
                    </div>

                </div>
                <!--BARRA DO RODAPÉ-->
                <div style="clear: both;">&nbsp;</div>
            </div>
        </div>

        <!--RODAPÉ-->
        <div id="footer">
            <p class="copyright">&copy;&nbsp;&nbsp;2009 All Rights Reserved &nbsp;&bull;&nbsp; Design by <a href="#">H1 Softwares</a>.</p>
            <p class="link"><a href="#">Privacy Policy</a>&nbsp;&#8226;&nbsp;<a href="#">Terms of Use</a></p>
        </div>
    </body>
</html>


